<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Blogger_Save extends Controller{

public function action_index()
{
	if ($_POST)
    {
		$blog = ORM::factory('blog');
		$blog->values(array(
			'user_id'     => Auth::instance()->get_user()->id,
			'name'        => arr::get($_POST, 'name'),
		    'url_feed'    => arr::get($_POST, 'blogFeedUrl'),
		    'description' => arr::get($_POST, 'descriptions'),
			'create_time' => time(),
		));
		$blog->save();

		$this->request->redirect('blogger/preference/id/'.$blog->id);
	}
	$this->request->redirect('');
}

/**
* Initialize properties before running the controller methods (actions),
* so they are available to our action.
*/
public function before()
{
	// Run anything that need ot run before this.
	parent::before();

	if (!Auth::instance()->logged_in())
	{
		$this->request->redirect('/user/login');
	}
}

}




